/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate.dialect.identity;

import org.hibernate.dialect.DatabaseVersion;

/**
 * @author Andrea Boriero
 */
public class HSQLIdentityColumnSupport extends IdentityColumnSupportImpl {
	final private DatabaseVersion dbVersion;

	public HSQLIdentityColumnSupport(DatabaseVersion dbVersion) {
		this.dbVersion = dbVersion;
	}

	@Override
	public boolean supportsIdentityColumns() {
		return true;
	}

	@Override
	public String getIdentityColumnString(int type) {
		//not null is implicit
		return "generated by default as identity (start with 1)";
	}

	@Override
	public String getIdentitySelectString(String table, String column, int type) {
		return "call identity()";
	}

	@Override
	public String getIdentityInsertString() {
		return dbVersion.isBefore( 2 ) ? "null" : "default";
	}
}
